<!--  -->
<template>
  <div class="rtb-con">
    <div class="rtb-row">
      <div class="item-row left">为方便后续业务办理，请告知我们您的电子税务局登录密码，密码将仅用于办理业务，我们将严格为您保密！</div>
      <div class="item-row center py-100"><div style="width: 140px;">电子税务局登录密码：</div><a-input-password v-model="password" placeholder="请输入电子税务局登录密码" allow-clear style="flex: 1;" /></div>
    </div>
    <div class="rtb-row">
      <div class="item-row">确认当前企业法人是否已完成法人实名采集 <a @click="gotoEvent" style="padding-left: 5px;">查看法人实名采集方法</a></div>
      <div class="item-row center py-100"><a-radio-group :options="plainOptions" v-model="radioVal" /></div>
    </div>
    <div class="rtb-row">
      <div class="item-row center">
        <a-button icon="left" style="width: 300px; margin: 5px;" @click="gobackEvent">返回上一步 </a-button>
        <a-button icon="check-circle" type="primary" style="width: 300px; margin: 5px;" @click="submitEvent" :disabled="buttonDisabled"> 提交</a-button>
      </div>
    </div>
  </div>
</template>

<script>
import getDataForDB from '@/api/qsbBusinessManagement'
export default {
  // import引入的组件需要注入到对象中才能使用
  name: 'RegisterTaxBureau1',
  components: {},
  props: {
    dataInfo:{type:Object},
    closeEvent:{type:Function}
  },
  data() {
    // 这里存放数据
    return {
      password:'',
      radioVal:'',
      buttonDisabled:false,
      plainOptions:[
        { label: '法人已完成实名采集', value: '2' },
        { label: '法人未完成实名采集', value: '1' },
      ]
    };
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {
    // radioVal: {
    //   handler(val) {
    //     if(val=='1'){
    //       this.buttonDisabled = true
    //     }
    //     this.buttonDisabled = false
    //   },
    // },
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  // 方法集合
  methods: {
    /**
     * 查看法人实名采集方法
     */
    gotoEvent(){
      this.closeEvent('howAuthenticate')
    },
    gobackEvent(){
      this.closeEvent('RegisterTaxBureau')
    },
    submitEvent(){
      if(this.isType.isEmpty(this.password)){
        this.$message.warning('电子税务局登录密码不能为空')
        return false
      }
      if(this.isType.isEmpty(this.radioVal)){
        this.$message.warning('请选择法人是否已完成实名采集')
        return false
      }
      const param = {
        "id": this.dataInfo.taxId,
        "taxAuth": this.radioVal,
        "taxPassword": this.password
      }
      getDataForDB('企业端电子税务局密码提交',param).then((result) => {
        if(result.success==true){
          this.$message.success('数据提交成功')
          this.closeEvent('Refresh')
        }else{
          if(result.message=='税务办理处于办理中,不允许操作'){
            this.closeEvent('Refresh')
            this.$message.info('当前流程已被更新，页面已强制刷新，请核对后操作')
          }else{
            this.$message.warning(result.message || '接口调用出错！')
          }
        }

      }).catch((err) => {
        this.$message.error(err)
        this.closeEvent('Refresh')
      });

    }
  },
  }
</script>
<style lang='less'>
.rtb-con{
  width: 100%;
  height: 300px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex-direction: column;
  border: 1px solid #c3c3c3;
  padding: 5px;
  box-sizing: border-box;
  .rtb-row{
    width: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    flex-direction: column;

    .item-row{
      width: 100%;
      display: flex;
      padding: 10px;
      &.left{
        justify-content: flex-start;
        align-items: flex-start;
      }
      &.center{
        justify-content: center;
        align-items: center;
      }
      &.right{
        align-items: flex-end;

      }
      &.py-100{
        padding: 0  100px;

      }
      &.pr-50{
        padding-right: 50px;
      }
      &.pl-10{
        padding-left: 10px;
      }

    }
  }
}
</style>

